Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

271
Views
Operator precedence in typescript shorthand array notation: typeof unknown[]

In puppeteer's declaration file types.d.ts, I came across the following type definition:

  export declare type EvaluateFunc<T extends unknown[]>
      = (...params: InnerParams<T>) => Awaitable<unknown>;


  export declare type InnerParams<T extends unknown[]> = {
      [K in keyof T]: FlattenHandle<T[K]>;
  };

My question is in regards to <T extends unknown[]> and the operator precedence for typeof and [] .. is T extending unknown? Or is it extending unknown[], and, if it's the latter, then is the keyof operator able to be used on type Array? If so, does typescript take this to mean 'any numeric property of an array'? (aka, array item).

Assuming it's the former, and T is extending unknown, then how does the array shorthand [] operator affect the typeof operator? Just for context, here is the definition for FlattenHandle:

export declare type FlattenHandle<T> = T extends HandleOr<infer U> ? U : never;

Sub-question: export declare -- I've taken a break from TS for half a year and now that I'm back, I'm seeing these more and more. Is it a recent addition? What are we trying to say here? That, the type exists but was not exported in the source? One of the affects of this export declare is that my IDE (PHPStorm) thinks that the class ElementHandle exists, and even appears in console.log, but, if you Console.log(ElementHandle) you will get undefined:

export declare class ElementHandle<ElementType extends Node = Element> extends JSHandle<ElementType> {
    #private;
    // ...

Thank you for your help.

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!